-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report collected results #9
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This change will enable us to display a visual report of the tests being run, so we can give feedback to users (instead of the program just blankly finishing) Checklist: - Invoke tearDown even if the test method fails - Run multiple tests - Report collected results 👈🏼 --- Output: ➜ python3 src/test_case_test.py Traceback (most recent call last): File "tdd-xunit-example/src/test_case_test.py", line 12, in <module> TestCaseTest("testTemplateMethod").run() File "tdd-xunit-example/src/test_case.py", line 12, in run method() File "tdd-xunit-example/src/test_case_test.py", line 9, in testTemplateMethod assert ("1 run, 0 failed" == result.summary()) ^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'summary'
kaiosilveira
force-pushed
the
chapter21/counting
branch
from
March 18, 2023 14:18
ab8b9a1
to
f7fbf89
Compare
This class will be used to hold a summary of the test suite execution. For now, though, it's just implementing a summary method with a hardcoded implementation. Checklist: - Invoke tearDown even if the test method fails - Run multiple tests - Report collected results 👈🏼 --- Output: ➜ python3 src/test_case_test.py Traceback (most recent call last): File "tdd-xunit-example/src/test_case_test.py", line 12, in <module> TestCaseTest("testTemplateMethod").run() File "tdd-xunit-example/src/test_case.py", line 12, in run method() File "tdd-xunit-example/src/test_case_test.py", line 9, in testTemplateMethod assert ("1 run, 0 failed" == result.summary()) ^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'summary'
Checklist: - Invoke tearDown even if the test method fails - Run multiple tests - Report collected results 👈🏼
This instance variable will be used to hold the number of tests there were ran in a test session. For now, though, it is hardcoded to the value 1. Checklist: - Invoke tearDown even if the test method fails - Run multiple tests - Report collected results 👈🏼
This method will be responsible for updating the value of runCount everytime a test is executed Checklist: - Invoke tearDown even if the test method fails - Run multiple tests - Report collected results 👈🏼 --- Output: ➜ python3 src/test_case_test.py Traceback (most recent call last): File "tdd-xunit-example/src/test_case_test.py", line 12, in <module> TestCaseTest("testTemplateMethod").run() File "tdd-xunit-example/src/test_case.py", line 15, in run method() File "tdd-xunit-example/src/test_case_test.py", line 9, in testTemplateMethod assert ("1 run, 0 failed" == result.summary()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError
kaiosilveira
force-pushed
the
chapter21/counting
branch
from
March 18, 2023 15:03
f7fbf89
to
ef45d97
Compare
This call is needed so we can increment the runCount variable and compute the number of tests ran in a session Checklist: - Invoke tearDown even if the test method fails - Run multiple tests - Report collected results 👈🏼
Checklist: - Invoke tearDown even if the test method fails - Run multiple tests - Report collected results 👈🏼 --- Output: ➜ python3 src/test_case_test.py Traceback (most recent call last): File "tdd-xunit-example/src/test_case_test.py", line 18, in <module> TestCaseTest("testFailedResult").run() File "tdd-xunit-example/src/test_case.py", line 17, in run method() File "tdd-xunit-example/src/test_case_test.py", line 13, in testFailedResult result = test.run() ^^^^^^^^^^ File "tdd-xunit-example/src/test_case.py", line 16, in run method = getattr(self, self.name) ^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'WasRun' object has no attribute 'testBrokenMethod'
This implementation will support the code being executed as part of TestCase.testFailedResult. For now, though, we're just raising an exception. Checklist: - Invoke tearDown even if the test method fails - Run multiple tests - Report collected results ✅ --- Output: ➜ python3 src/test_case_test.py Traceback (most recent call last): File "tdd-xunit-example/src/test_case_test.py", line 18, in <module> TestCaseTest("testFailedResult").run() File "tdd-xunit-example/src/test_case.py", line 17, in run method() File "tdd-xunit-example/src/test_case_test.py", line 13, in testFailedResult result = test.run() ^^^^^^^^^^ File "tdd-xunit-example/src/test_case.py", line 17, in run method() File "tdd-xunit-example/src/was_run.py", line 20, in testBrokenMethod raise Exception Exception
kaiosilveira
force-pushed
the
chapter21/counting
branch
from
March 18, 2023 15:07
ef45d97
to
47adee2
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Chapter 21: Counting
Our goal is this chapter was to collect a summary of the test execution. We accomplish that by implementing a
TestResult
class that will be responsible for holding these results and displaying then when requested.Implementation checklist:
✅
Invoke tearDown afterward☑️ Invoke tearDown even if the test method fails
☑️ Run multiple tests
✅
Report collected results✅
Log string in WasRunCloses #7